<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>pg_rewrite</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REV="MADE"
HREF="mailto:pgsql-docs@postgresql.org"><LINK
REL="HOME"
TITLE="PostgreSQL 9.1.2 Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="System Catalogs"
HREF="catalogs.html"><LINK
REL="PREVIOUS"
TITLE="pg_proc"
HREF="catalog-pg-proc.html"><LINK
REL="NEXT"
TITLE="pg_seclabel"
HREF="catalog-pg-seclabel.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="stylesheet.css"><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=ISO-8859-1"><META
NAME="creation"
CONTENT="2011-12-01T22:07:59"></HEAD
><BODY
CLASS="SECT1"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="5"
ALIGN="center"
VALIGN="bottom"
><A
HREF="index.html"
>PostgreSQL 9.1.2 Documentation</A
></TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
TITLE="pg_proc"
HREF="catalog-pg-proc.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="catalogs.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="60%"
ALIGN="center"
VALIGN="bottom"
>Chapter 45. System Catalogs</TD
><TD
WIDTH="20%"
ALIGN="right"
VALIGN="top"
><A
TITLE="pg_seclabel"
HREF="catalog-pg-seclabel.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="CATALOG-PG-REWRITE"
>45.36. <TT
CLASS="STRUCTNAME"
>pg_rewrite</TT
></A
></H1
><P
>   The catalog <TT
CLASS="STRUCTNAME"
>pg_rewrite</TT
> stores rewrite rules for tables and views.
  </P
><DIV
CLASS="TABLE"
><A
NAME="AEN88029"
></A
><P
><B
>Table 45-36. <TT
CLASS="STRUCTNAME"
>pg_rewrite</TT
> Columns</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><COL><COL><THEAD
><TR
><TH
>Name</TH
><TH
>Type</TH
><TH
>References</TH
><TH
>Description</TH
></TR
></THEAD
><TBODY
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>rulename</TT
></TD
><TD
><TT
CLASS="TYPE"
>name</TT
></TD
><TD
>&nbsp;</TD
><TD
>Rule name</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>ev_class</TT
></TD
><TD
><TT
CLASS="TYPE"
>oid</TT
></TD
><TD
><TT
CLASS="LITERAL"
><A
HREF="catalog-pg-class.html"
><TT
CLASS="STRUCTNAME"
>pg_class</TT
></A
>.oid</TT
></TD
><TD
>The table this rule is for</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>ev_attr</TT
></TD
><TD
><TT
CLASS="TYPE"
>int2</TT
></TD
><TD
>&nbsp;</TD
><TD
>The column this rule is for (currently, always zero to
      indicate the whole table)</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>ev_type</TT
></TD
><TD
><TT
CLASS="TYPE"
>char</TT
></TD
><TD
>&nbsp;</TD
><TD
>       Event type that the rule is for: 1 = <TT
CLASS="COMMAND"
>SELECT</TT
>, 2 =
       <TT
CLASS="COMMAND"
>UPDATE</TT
>, 3 = <TT
CLASS="COMMAND"
>INSERT</TT
>, 4 =
       <TT
CLASS="COMMAND"
>DELETE</TT
>
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>ev_enabled</TT
></TD
><TD
><TT
CLASS="TYPE"
>char</TT
></TD
><TD
>&nbsp;</TD
><TD
>       Controls in which <A
HREF="runtime-config-client.html#GUC-SESSION-REPLICATION-ROLE"
>session_replication_role</A
> modes
       the rule fires.
       <TT
CLASS="LITERAL"
>O</TT
> = rule fires in <SPAN
CLASS="QUOTE"
>"origin"</SPAN
> and <SPAN
CLASS="QUOTE"
>"local"</SPAN
> modes,
       <TT
CLASS="LITERAL"
>D</TT
> = rule is disabled,
       <TT
CLASS="LITERAL"
>R</TT
> = rule fires in <SPAN
CLASS="QUOTE"
>"replica"</SPAN
> mode,
       <TT
CLASS="LITERAL"
>A</TT
> = rule fires always.
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>is_instead</TT
></TD
><TD
><TT
CLASS="TYPE"
>bool</TT
></TD
><TD
>&nbsp;</TD
><TD
>True if the rule is an <TT
CLASS="LITERAL"
>INSTEAD</TT
> rule</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>ev_qual</TT
></TD
><TD
><TT
CLASS="TYPE"
>pg_node_tree</TT
></TD
><TD
>&nbsp;</TD
><TD
>       Expression tree (in the form of a
       <CODE
CLASS="FUNCTION"
>nodeToString()</CODE
> representation) for the
       rule's qualifying condition
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>ev_action</TT
></TD
><TD
><TT
CLASS="TYPE"
>pg_node_tree</TT
></TD
><TD
>&nbsp;</TD
><TD
>       Query tree (in the form of a
       <CODE
CLASS="FUNCTION"
>nodeToString()</CODE
> representation) for the
       rule's action
      </TD
></TR
></TBODY
></TABLE
></DIV
><DIV
CLASS="NOTE"
><BLOCKQUOTE
CLASS="NOTE"
><P
><B
>Note: </B
>    <TT
CLASS="LITERAL"
>pg_class.relhasrules</TT
>
    must be true if a table has any rules in this catalog.
   </P
></BLOCKQUOTE
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="catalog-pg-proc.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="catalog-pg-seclabel.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><TT
CLASS="STRUCTNAME"
>pg_proc</TT
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="catalogs.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><TT
CLASS="STRUCTNAME"
>pg_seclabel</TT
></TD
></TR
></TABLE
></DIV
></BODY
></HTML
>